home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / SeeMovieRun 2.0 / Source / x_CAboutBox.cp < prev    next >
Encoding:
Text File  |  1995-08-02  |  9.8 KB  |  379 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  x_CAboutBox.cp
  3.  
  4.                 CAboutBox Dialog Director Class
  5.     
  6.     Copyright Â© 1995 Gregory Bonk for NewMedia Inc.. All rights reserved.
  7.  
  8.     Generated by Visual Architectâ„¢
  9.  
  10.     This file is rewritten each time you generate code. You should not
  11.     make changes to this file; changes should go in the CAboutBox.cp
  12.     file, instead.
  13.  
  14.     If you want to change how Visual Architect generates this file, you can
  15.     change the template for this file. It is "_Dialog_cp" in the Visual Architect
  16.     Templates folder.
  17.  
  18.  ******************************************************************************/
  19.  
  20. #include "x_CAboutBox.h"
  21.  
  22. #include "AboutBoxItems.h"
  23.  
  24. #include "ViewUtilities.h"
  25.  
  26. #include <CIntegerText.h>
  27. #include <Commands.h>
  28. #include <CControl.h>
  29. #include <CPopupMenu.h>
  30. #include <CPopupPane.h>
  31. #include <CArrayPane.h>
  32. #include <CIconButton.h>
  33. #include <CPictureButton.h>
  34. #include <CSwissArmyButton.h>
  35.  
  36. #include "CIconPane.h"
  37. #include "CStaticText.h"
  38. #include "CButton.h"
  39.  
  40.  
  41. #include <CApplication.h>
  42. #include <CBartender.h>
  43. #include <Commands.h>
  44. #include <Constants.h>
  45. #include <CDecorator.h>
  46. #include <CDesktop.h>
  47. #include <CDirectorOwner.h>
  48. #include <CFile.h>
  49. #include <CList.h>
  50. #include <CPanorama.h>
  51. #include <TBUtilities.h>
  52. #include <CWindow.h>
  53.  
  54. extern    CApplication *gApplication;        /* The application                    */
  55. extern CDecorator    *gDecorator;        /* Decorator for arranging windows    */
  56. extern CDesktop        *gDesktop;            /* The visible Desktop                */
  57. extern CBartender    *gBartender;        /* Manages all menus                */
  58.  
  59.     // Define symbols for commands handled by this class
  60.     // Prevents a recompile every time any command changed.
  61.  
  62.  
  63. TCL_DEFINE_CLASS_M1(x_CAboutBox, CDialogDirector);
  64.  
  65. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  66.  
  67.  
  68. /******************************************************************************
  69.  Ix_CAboutBox
  70.  
  71.     Initialize the dialog
  72.  ******************************************************************************/
  73.  
  74. void x_CAboutBox::Ix_CAboutBox(CDirectorOwner *aSupervisor, Boolean push)
  75.  
  76. {
  77.     IDialogDirector(aSupervisor);
  78.  
  79.         // There are several circumstances where we don't want
  80.         // ProviderChanged to be called. During initialization,
  81.         // during calls to UpdateData, etc. The ignore flag
  82.         // heads these off.
  83.  
  84.     ignore = TRUE;                        /* Don't call UpdateData now        */
  85.  
  86.     MakeNewWindow();                    /* Create the dialog's window        */
  87.  
  88.     DoBeginData(push);                    /* Gather initial values            */
  89.  
  90.     ignore = FALSE;
  91. }
  92.  
  93.  
  94. /******************************************************************************
  95.  MakeNewWindow
  96.  
  97.     Create a window by reading a view resource
  98.  ******************************************************************************/
  99.  
  100. void x_CAboutBox::MakeNewWindow(void)
  101.  
  102. {
  103.     itsWindow = TCLGetNamedWindow("\pAboutBox", this);
  104.  
  105.         // Initialize pointers to the subpanes in the window
  106.  
  107.   fAboutBox_Icon1 = (CIconPane*) FindPane(kAboutBox_Icon1ID);
  108.   ASSERT(member(fAboutBox_Icon1, CIconPane));
  109.  
  110.   fAboutBox_Stat2 = (CStaticText*) FindPane(kAboutBox_Stat2ID);
  111.   ASSERT(member(fAboutBox_Stat2, CStaticText));
  112.  
  113.   fAboutBox_Stat3 = (CStaticText*) FindPane(kAboutBox_Stat3ID);
  114.   ASSERT(member(fAboutBox_Stat3, CStaticText));
  115.  
  116.   fAboutBox_Stat4 = (CStaticText*) FindPane(kAboutBox_Stat4ID);
  117.   ASSERT(member(fAboutBox_Stat4, CStaticText));
  118.  
  119.   fAboutBox_Stat6 = (CStaticText*) FindPane(kAboutBox_Stat6ID);
  120.   ASSERT(member(fAboutBox_Stat6, CStaticText));
  121.  
  122.   fAboutBox_Butn7 = (CButton*) FindPane(kAboutBox_Butn7ID);
  123.   ASSERT(member(fAboutBox_Butn7, CButton));
  124.  
  125.   fAboutBox_Stat8 = (CStaticText*) FindPane(kAboutBox_Stat8ID);
  126.   ASSERT(member(fAboutBox_Stat8, CStaticText));
  127.  
  128.   fAboutBox_Stat11 = (CStaticText*) FindPane(kAboutBox_Stat11ID);
  129.   ASSERT(member(fAboutBox_Stat11, CStaticText));
  130.  
  131. }
  132.  
  133.  
  134. /******************************************************************************
  135.  FindPane
  136.  
  137.     Locate a subpane of this window by ID. Note that Visual Architect-
  138.     generated IDs are unique within a project, so this function
  139.     will find panes within subviews, even if dynamically loaded.
  140.  ******************************************************************************/
  141.  
  142. CPane *x_CAboutBox::FindPane(long ID)
  143.  
  144. {
  145.     return (CPane*) itsWindow->FindViewByID(ID);
  146. }
  147.  
  148.  
  149. /******************************************************************************
  150.  DoBeginData
  151.  
  152.      Collect initial values from subclass and initialize panes
  153. ******************************************************************************/
  154.  
  155. void x_CAboutBox::DoBeginData(Boolean push)
  156.  
  157. {
  158.     CAboutBoxData        data = {0};        /* The initial value record            */
  159.  
  160.     BeginData(&data);                    // Ask subclass for initial values
  161.  
  162.     if (!push)
  163.     {
  164.         DispensePaneValues(data);        // Set panes
  165.     }
  166.  
  167.         // Save the initial values in case user cancels
  168.  
  169.     saveData = data;
  170. }
  171.  
  172.  
  173. /******************************************************************************
  174.  DoEndData
  175.  
  176.      Collect final values from panes and tell subclass.
  177.      During EndData(), data argument has current values and
  178.      saveData has initial values. After EndData(), saveData
  179.      holds current values.
  180. ******************************************************************************/
  181.  
  182. void x_CAboutBox::DoEndData(long theCommand)
  183.  
  184. {
  185.     CAboutBoxData        data;            /* The initial value record            */
  186.     RgnHandle            rgn;            /* Selection region                    */
  187.  
  188.                                         /* If user canceled the dialog,        */
  189.     if (theCommand == cmdCancel)        /*     return the initial values        */
  190.     {
  191.         data = saveData;
  192.     }
  193.     else
  194.         CollectPaneValues(data);        // Get current pane values
  195.  
  196.     EndData(&data);                        // Tell the derived class
  197.  
  198.     saveData = data;                    // Now has current values
  199. }
  200.  
  201.  
  202. /******************************************************************************
  203.  SetData
  204.  
  205.      Set initial values of panes. Must be called after I-function. (2.0.5)
  206. ******************************************************************************/
  207.  
  208. void x_CAboutBox::SetData(const CAboutBoxData& initial)
  209. {
  210.     DispensePaneValues(initial);
  211.     saveData = initial;
  212. }
  213.  
  214.  
  215. /******************************************************************************
  216.  GetData
  217.  
  218.      Collect final values from panes. Must be called after DoEndData
  219.      (which means it is usually only meaningful for modal dialogs,
  220.      as modeless dialogs usually call DoEndData during Close()). (2.0.5)
  221. ******************************************************************************/
  222.  
  223. void x_CAboutBox::GetData(CAboutBoxData& final)
  224. {
  225.     final = saveData;
  226. }
  227.  
  228.  
  229. /******************************************************************************
  230.  DispensePaneValues
  231.  
  232.      Set pane values from argument struct
  233. ******************************************************************************/
  234.  
  235. void x_CAboutBox::DispensePaneValues(const CAboutBoxData& data)
  236.  
  237. {
  238.         // Initialize the panes based on the values supplied.
  239.         // The ASSERT statements ensure that the generated
  240.         // code is in synch with the view resource.
  241.  
  242. }
  243.  
  244. /******************************************************************************
  245.  CollectPaneValues
  246.  
  247.      Collect final values from panes and tell subclass
  248. ******************************************************************************/
  249.  
  250. void x_CAboutBox::CollectPaneValues(CAboutBoxData& data)
  251.  
  252. {
  253.     RgnHandle            rgn;            /* Selection region                    */
  254.  
  255.                                         /* Collect values from panes        */
  256. }
  257.  
  258.  
  259. /******************************************************************************
  260.  BeginData
  261.  
  262.      Collect initial values from subclass and initialize panes.
  263.      The default function does nothing.
  264. ******************************************************************************/
  265.  
  266. void x_CAboutBox::BeginData(CAboutBoxData *initial)
  267.  
  268. {
  269. }
  270.  
  271.  
  272. /******************************************************************************
  273.  UpdateData
  274.  
  275.      Tell subclass when panes change
  276. ******************************************************************************/
  277.  
  278. void x_CAboutBox::UpdateData(CAboutBoxUpdate *update, long itemNo)
  279.  
  280. {
  281. }
  282.  
  283.  
  284. /******************************************************************************
  285.  EndData
  286.  
  287.      Tell subclass the final values. For a canceled modal dialog,
  288.      these are the same as the initial values.
  289. ******************************************************************************/
  290.  
  291. void x_CAboutBox::EndData(CAboutBoxData *final)
  292.  
  293. {
  294. }
  295.  
  296.  
  297. /******************************************************************************
  298.  DoModalDialog    {OVERRIDE}
  299.  
  300.      Override to call EndData
  301. ******************************************************************************/
  302.  
  303. long x_CAboutBox::DoModalDialog(long defaultCmd)
  304.  
  305. {
  306.     long    result = CDialogDirector::DoModalDialog(defaultCmd);
  307.     
  308.     DoEndData(result);
  309.     return result;
  310. }
  311.  
  312.  
  313. /******************************************************************************
  314.  Close {OVERRIDE}
  315.  
  316.      Override to call EndData
  317. ******************************************************************************/
  318.  
  319. Boolean x_CAboutBox::Close(Boolean quitting)
  320.  
  321. {    
  322.     if (itsWindow && !itsWindow->active)
  323.         itsWindow->Select();
  324.  
  325.     if (EndDialog(cmdOK, TRUE))
  326.     {                                        
  327.                                         /* For a modal dialog, exit through    */
  328.         if (itsWindow->IsModal())        /*     DoModalDialog                    */
  329.         {
  330.             dismissCmd = cmdClose;
  331.             return TRUE;
  332.         }
  333.         else
  334.         {
  335.                                         /* Collect final values and call    */
  336.             DoEndData(cmdOK);            /*     EndData                        */
  337.                                         /* Do the Close, skipping            */
  338.                                         /*     CDialogDirector (7.0.4)        */
  339.             return CDirector::Close(quitting);
  340.         }
  341.     }
  342.     else
  343.         return FALSE;
  344. }
  345.  
  346.  
  347. /******************************************************************************
  348.  ProviderChanged    {OVERRIDE}
  349.      
  350.      User did something. Note that the TCL
  351.      does not currently report changes to plain CEditText items. 
  352. ******************************************************************************/
  353.  
  354. void x_CAboutBox::ProviderChanged(CCollaborator *aProvider, long reason, void* info)
  355.  
  356. {
  357.     CAboutBoxUpdate    data;            /* The update value record            */
  358.     Str255    str;
  359.     Boolean    saveIgnore = ignore;
  360.     
  361.     if (ignore)                            /* Don't be a chatterbox            */
  362.         return;
  363.     ignore = TRUE;
  364.     
  365.     TRY
  366.     {
  367.          if (FALSE) {}
  368.         else
  369.             CDialogDirector::ProviderChanged(aProvider, reason, info);
  370.     }
  371.     CATCH
  372.         ignore = saveIgnore;
  373.     ENDTRY
  374.     
  375.     ignore = saveIgnore;                /* ProviderChanged() can't Close()!    */
  376. }
  377.  
  378.  
  379.